﻿using System.Collections.ObjectModel;
using System.Windows.Input;
using ETask.Client.Models;

namespace ETask.Client.ViewModels
{
    public class GroupViewModel:ViewModelBase
    {
        private ObservableCollection<ProjectItem> _projectItems;
        public ObservableCollection<ProjectItem> ProjectItems
        {
            get => _projectItems;
            set => SetProperty(ref _projectItems, value);
        }

        private ObservableCollection<ProjectItem> _selectedProjectItems;
        public ObservableCollection<ProjectItem> SelectedProjectItems
        {
            get => _selectedProjectItems;
            set => SetProperty(ref _selectedProjectItems, value);
        }
        public ICommand CancelCommand { get; }

        public event EventHandler CloseRequested;

        public GroupViewModel() 
        {
            this.ProjectItems = new ObservableCollection<ProjectItem>();
            this.ProjectItems.Add(new ProjectItem
            {
                Id = "1",
                ProjectName = "客商管理系统"
            });
            this.ProjectItems.Add(new ProjectItem
            {
                Id = "2",
                ProjectName = "主平台升级"
            });
            this.ProjectItems.Add(new ProjectItem
            {
                Id = "3",
                ProjectName = "安全系统升级"
            });
            CancelCommand = new RelayCommand(CloseWindow);
        }

        private void CloseWindow()
        {
            if (CloseRequested != null)
            {
                CloseRequested(this, EventArgs.Empty);
            }
        }

    }
}
